		
		//创建文件夹
		function createFolder(folderName,elementId){
				//在根目录创建文件夹
				var newFolderId = uuid().substring(0,10);
				var parentFolderId = document.getElementById("parentFolderId").value;
				console.log(parentFolderId);
				var json = {"userId":$("#userId").val(),"folderId":newFolderId,"parentFolderId":parentFolderId,"folderName":folderName};
				var url = getBasePath()+"/json/FolderAction_createFolder.action";
				console.log("newFolder="+json);
				var strJson = JSON.stringify(json);
				console.log("newFolder转换后="+strJson);
				$(function(){
					$.ajax({
					type:"POST",
					dataType:"JSON",
					url:url,
					data:{"newFolder":strJson,},
					success: function(message){
						var json = eval("("+message+")");
						if(json.isSuccess == "true"){
							alert("创建成功！");
							$(elementId).prev().css("display","none");
							$(elementId).prev().before("<span>"+$(elementId).prev().val()+"</span>");
							$(elementId).css("display","none");
							$(elementId).nextAll().css("display","none");
							i++;
							updateAllFileNum(1);
							$("#allFileNum").html("已全部加载，共"+initFileNum+"个");
							refresh();
							//使顶部按钮生效
							forbitTopBtn(false);
						}
						else{
							alert("错误"+message);
							alert("创建失败！");
						}
					},
				});
			});
		}
		
		//重命名
		function rename(element){
			$(function(){
					var oldA = $(element).prevAll("span").html();
					var oldName = $(element).prevAll("span").text().trim();
					var insertInput = 
	    					"<input type='text' id='newInput"+i+"' name='newInput"+i+"' value='"+oldName+"' autofocus onfocus='this.select()'/>"
	    					+"<img src='images/insure.png' id='renameInsure' width='21.6' height='21.6' />"
	    					+"<img src='images/cancel.png' id='renameCancel' width='21.6' height='21.6' />";
	    			$(element).hide();
	    			$(element).prevAll("span").before(insertInput);
					$(element).prevAll("span").remove();
					$("#renameInsure").on('click',(function(){
						//修改文件夹名
						var folderId = $(this).prevAll("input[name='folderId']").val();
						var newFolderName = $(this).prev().val();
						//修改文件名
						var fileId = $(this).prevAll("input[name='fileId']").val();
						var newFileName = $(this).prev().val();
						saveNewName($(this),folderId,newFolderName,fileId,newFileName);
					}));
					$("#renameCancel").on('click',(function(){
						$(this).prev().prev().remove();
						$(this).prev().remove();
						$(this).before("<span>"+oldA+"</span>");
						$(this).nextAll(".rename").show();
						$(this).remove();
					}));
			});
		}
		
		//保存新的文件名
		function saveNewName(element,folderId,newFolderName,fileId,newFileName){
				var folderJson= {"folderId":folderId,"newFolderName":newFolderName};
				var fileJson = {"fileId":fileId,"newFileName":newFileName};
				var url = getBasePath()+"/json/FileAction_editName.action";
				console.log("修改前文件夹名json="+folderJson);
				console.log("修改前文件名json="+fileJson);
				folderJson = JSON.stringify(folderJson);
				fileJson = JSON.stringify(fileJson);
				console.log("修改文件夹名json转换后="+folderJson);
				console.log("修改文件名json转换后="+fileJson);
				$(function(){
					$.ajax({
					type:"POST",
					dataType:"JSON",
					url:url,
					data:{"editFolder":folderJson,"editFile":fileJson,},
					success: function(message){
						var json = eval("("+message+")");
						if(json.isSuccess == "true"){
							alert("修改成功！");
							$(element).prev().remove();
							$(element).before("<span>"+newFolderName+"</span>");
							$(element).next().remove();
							$(element).nextAll(".rename").show();
							$(element).remove();
							refresh();
						}
						else{
							alert("错误"+message);
							alert("修改失败！");
						}
					},
				});
			});
		}
		
		//删除文件夹或文件
		function deleteFolderOrFile(deleteFolderArray,deleteFileArray){
			var url = getBasePath()+"/json/FileAction_IntoRecycleBin.action";
			$.ajax({
				type:"POST",
				dataType:"JSON",
				url:url,
				data:{"strSelectedFolder":JSON.stringify(deleteFolderArray),"strSelectedFile":JSON.stringify(deleteFileArray)},
				success: function(message){
					var json = eval("("+message+")");
					if(json.isSuccess == "true"){
						i--;
						alert("删除成功！");
						$("input[name='selectedFolder']:checked").each(function(){
							$(this).parent().parent().remove();
						});
						$("input[name='selectedFile']:checked").each(function(){
							$(this).parent().parent().remove();
						});
						//删除了全部文件夹和文件则显示没有文件图片
						if(getAllFolderAndFile() == 0){
							$(".no-result-file-download").show();
						}
						updateAllFileNum(-1);
						$("#allFileNum").html("已全部加载，共"+initFileNum+"个");
					}
					else{
						alert("错误"+message);
						alert("删除失败！");
					}
				},
			});
		}	
		//修改文件夹或文件浏览权限
		function editPermissions(selectedFolderArray,selectedFileArray){
			var url = getBasePath()+"/json/FileAction_editPermissions.action";
			$.ajax({
				type:"POST",
				dataType:"JSON",
				url:url,
				data:{"strSelectedFolder":JSON.stringify(selectedFolderArray),"strSelectedFile":JSON.stringify(selectedFileArray)},
				success: function(message){
					var json = eval("("+message+")");
					if(json.isSuccess == "true"){
						alert("修改浏览权限成功！");
					}
					else{
						alert("修改浏览权限失败！");
					}
				},
			});
		}
		
		//恢复文件夹或文件
		function restoreFolderOrFile(restoreFolderArray,restoreFileArray){
			var url = getBasePath()+"/json/FileAction_restoreFolderOrFile.action";
			$.ajax({
				type:"POST",
				dataType:"JSON",
				url:url,
				data:{"strSelectedFolder":JSON.stringify(restoreFolderArray),"strSelectedFile":JSON.stringify(restoreFileArray),},
				success: function(message){
					var json = eval("("+message+")");
					if(json.isSuccess == "true"){
						i--;
						alert("还原成功！");
						$("input[name='selectedFolder']:checked").each(function(){
							$(this).parent().parent().remove();
						});
						$("input[name='selectedFile']:checked").each(function(){
							$(this).parent().parent().remove();
						});
						updateAllFileNum(-1);
						$("#allFileNum").html("已全部加载，共"+initFileNum+"个");
					}
					else{
						alert("还原失败！");
					}
				},
			});
		}
		
		//删除回收站的文件
		function deleteRealFile(deleteFolderArray,deleteFileArray){
			var url = getBasePath()+"/json/FileAction_deleteFile.action";
			$.ajax({
				type:"POST",
				dataType:"JSON",
				url:url,
				data:{"strSelectedFolder":JSON.stringify(deleteFolderArray),"strSelectedFile":JSON.stringify(deleteFileArray)},
				success: function(message){
					var json = eval("("+message+")");
					if(json.isSuccess == "true"){
						i--;
						alert("删除成功！");
						$("input[name='selectedFolder']:checked").each(function(){
							$(this).parent().parent().remove();
						});
						$("input[name='selectedFile']:checked").each(function(){
							$(this).parent().parent().remove();
						});
						updateAllFileNum(-1);
						$("#allFileNum").html("已全部加载，共"+initFileNum+"个");
					}
					else{
						alert("错误"+message);
						alert("删除失败！");
					}
				},
			});
		}
		
		//添加好友
		function addFriends(addFriendsArray){
			var userId = $("#userId").val();
			var url = getBasePath()+"/json/FriendsAction_addFriends.action?user.userId="+userId;
			$.ajax({
				type:"POST",
				dataType:"JSON",
				url:url,
				data:{"strSelectedUser":JSON.stringify(addFriendsArray),},
				success: function(message){
					var json = eval("("+message+")");
					if(json.isSuccess == "true"){
						alert("添加好友请求已发送");
						var len = getAllSelectedUser();
						$("input[name='selectedUser']:checked").each(function(){
							$(this).parent().parent().remove();
						});
						updateAllFileNum(-len);
						$("#allFileNum").html("已全部加载，共"+initFileNum+"个");
					}
					else{
						alert("添加失败！");
					}
				},
			});
		}
		
		//删除好友
		function deleteFriends(deleteFriendsArray){
			var userId = $("#userId").val();
			var url = getBasePath()+"/json/FriendsAction_deleteFriends.action?user.userId="+userId;
			$.ajax({
				type:"POST",
				dataType:"JSON",
				url:url,
				data:{"strSelectedUser":JSON.stringify(deleteFriendsArray),},
				success: function(message){
					var json = eval("("+message+")");
					if(json.isSuccess == "true"){
						alert("删除成功！");
						$("input[name='selectedUser']:checked").each(function(){
							$(this).parent().parent().remove();
						});
						updateAllFileNum(-deleteFriendsArray.length);
						$("#allFileNum").html("已全部加载，共"+initFileNum+"个");
					}
					else{
						alert("删除失败！");
					}
				},
			});
		}
		
		//确认添加好友
		function confirmAddFriends(confirmAddFriendsArray){
			var userId = $("#userId").val();
			var url = getBasePath()+"/json/FriendsAction_confirmAddFriends.action?user.userId="+userId;
			$.ajax({
				type:"POST",
				dataType:"JSON",
				url:url,
				data:{"strSelectedUser":JSON.stringify(confirmAddFriendsArray),},
				success: function(message){
					var json = eval("("+message+")");
					if(json.isSuccess == "true"){
						alert("添加好友成功！");
						$("input[name='selectedUser']:checked").each(function(){
							$(this).parent().parent().remove();
						});
						var len = getAllSelectedUser();
						updateAllFileNum(-len);
						$("#allFileNum").html("已全部加载，共"+initFileNum+"个");
					}
					else{
						alert("添加失败！");
					}
				},
			});
		}
		
		//审核用户
		function audit(approvedArray){
			var url = getBasePath()+"/json/UserAction_auditUserList.action";
			$.ajax({
				type:"POST",
				dataType:"JSON",
				url:url,
				data:{"selectedUser":JSON.stringify(approvedArray),},
				success: function(message){
					var json = eval("("+message+")");
					if(json.isSuccess == "true"){
						alert("审核成功！");
						$("input[name='selectedUser']:checked").each(function(){
							$(this).parent().parent().remove();
						});
						var len = getAllSelectedUser();
						updateAllFileNum(-len);
						$("#allFileNum").html("已全部加载，共"+initFileNum+"个");
					}
					else{
						alert("审核失败！");
					}
				},
			});
			
		}
		var time = 100*3; 
		setInterval(topRefresh,time);  
		//定时刷新顶部，获取好友添加请求消息
		function topRefresh(){
			var onlineUserId = $('#topFrame', window.parent.document).contents().find("#topUserId").val();
			var url = getBasePath()+"/json/FriendsAction_haveNewFriend.action";
			$.ajax({
				type:"POST",
				dataType:"JSON",
				url:url,
				data:{"strSelectedUser":JSON.stringify(onlineUserId),},
				success: function(message){
					var json = eval("("+message+")");
					if(json.hasNewFriend == "true"){
						$('#topFrame', window.parent.document).contents().find("#newMessage").show();
						$('#topFrame', window.parent.document).contents().find("#myMessage").attr("title","有新的好友请求");
						//console.log("show ?"+$('#topFrame', window.parent.document).contents().find("#newMessage").attr("display"));
					}
					else{
						$('#topFrame', window.parent.document).contents().find("#newMessage").hide();
						$('#topFrame', window.parent.document).contents().find("#myMessage").attr("title","暂无消息");
					}
				},
			});
		}
